package com.example.nightmeel.vo;

import android.os.Parcel;
import android.os.Parcelable;

@SuppressWarnings("unchecked")
public class ContentValueObject implements Comparable, Parcelable {
    // アクセス用プロパティ
    private Long id = null;
    private String message = "";
    private int size = 0;
    private int isAd = 0;
    private int user_id = 0;
    private String user_name = "";
    private int category = 0;
    private int meal_type = 0;    // 朝食/昼食/夕食
    private int season = 0;       // 春夏秋冬
    private String geotag = "";
    private String img = "";
    private int sibo_count = 0;        // 脂肪ボタンを押された回数
    private String update = ""; // 投稿日時

    /**
     * デフォルトコンストラクタ
     */
    public ContentValueObject() {

    }

    /**
     * Parcelable用コンストラクタ
     *
     * @param in
     */
    public ContentValueObject(Parcel in) {
        id = in.readLong();
        message = in.readString();
        size = in.readInt();
        isAd = in.readInt();
        user_id = in.readInt();
        user_name = in.readString();
        category = in.readInt();
        meal_type = in.readInt();
        season = in.readInt();
        geotag = in.readString();
        img = in.readString();
        sibo_count = in.readInt();
        update = in.readString();
    }

    // アクセサメソッド
    public Long getId() {
        return id;
    }

    public String getMessage() {
        return message;
    }

    public int getSize() {
        return size;
    }

    public int getInt() {
        return isAd;
    }

    public int getUser_id() {
        return user_id;
    }

    public String getUser_name() {
        return user_name;
    }

    public int getCategory() {
        return category;
    }

    public int getMeal_type() {
        return meal_type;
    }

    public int getSeason() {
        return season;
    }

    public String getGeotag() {
        return geotag;
    }

    public String getImg() {
        return img;
    }

    public int getSibo_count() {
        return sibo_count;
    }

    public String getUpdate() {
        return update;
    }

    public void setId(Long id) {
        this.id = id;
    }



    public void setMessage(String message) {
        this.message = message;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public void setIsAd(int isAd) {
        this.isAd = isAd;
    }

    public void setUser(int user_id) {
        this.user_id = user_id;
    }

    public void setCategory(int category) {
        this.category = category;
    }

    public void setMeal_type(int meal_type) {
        this.meal_type = meal_type;
    }

    public void setComp_time(int season) {
        this.season = season;
    }

    public void setGeotag(String geotag) {
        this.geotag = geotag;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public void setSibo_count(int sibo_count) {
        this.sibo_count = sibo_count;
    }

    public void setUpdate(String update) {
        this.update = update;
    }

    /**
     * Parcelableインタフェースの抽象メソッドを実装
     */
    @Override
    public int describeContents() {
        return 0;
    }

    /**
     * Parcelableインタフェースの抽象メソッドを実装
     */
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(id);
        dest.writeString(message);
        dest.writeInt(size);
        dest.writeInt(isAd);
        dest.writeInt(user_id);
        dest.writeString(user_name);
        dest.writeInt(category);
        dest.writeInt(meal_type);
        dest.writeInt(season);
        dest.writeString(geotag);
        dest.writeString(img);
        dest.writeInt(sibo_count);
        dest.writeString(update);
    }

    public static final Parcelable.Creator<ContentValueObject> CREATOR = new Parcelable.Creator<ContentValueObject>() {
        public ContentValueObject createFromParcel(Parcel in) {
            return new ContentValueObject(in);
        }

        public ContentValueObject[] newArray(int size) {
            return new ContentValueObject[size];
        }
    };

    /**
     * idを比較するメソッド
     */
    @Override
    public int compareTo(Object another) {
        ContentValueObject t = (ContentValueObject) another;
        Long id2 = t.getId();

        if (this.id < id2) {
            return 1;
        } else if (this.id > id2) {
            return -1;
        } else {
            return 0;
        }
    }
}
